package gold.digger;

/**
 * Created by fanzhenyu02 on 2020/6/27.
 * common problem solver template.
 */
public class LC470 {
    public long startExecuteTime = System.currentTimeMillis();


    class SolBase {
        public int rand7() {
            return (int) (Math.random() * 7) + 1;
        }
    }

    class Solution extends SolBase {
        public int rand10() {
            int num = 100;
            while (num > 39) {
                num = (rand7() - 1) * 7 + rand7() - 1;
            }

            return num % 10 + 1;
        }
    }

    public void run() {
        Solution solution = new Solution();
        SolBase solBase = new SolBase();

        int[] count = new int[10];
        for (int i = 0; i < 10000; i++) {
            count[solution.rand10() - 1]++;
        }

        for (int i = 0; i < count.length; i++) {
            System.out.println(i + 1 + " : " + count[i]);
        }

    }

    public static void main(String[] args) throws Exception {
        LC470 an = new LC470();
        an.run();

        System.out.println("\ncurrent solution total execute time: " + (System.currentTimeMillis() - an.startExecuteTime) + " ms.");
    }
}
